package com.tanhua.server.controller;

import com.tanhua.model.vo.PageResult;
import com.tanhua.server.service.CommentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Map;

@RestController
@RequestMapping("/comments")
public class CommentsController {

    @Autowired
    private CommentsService commentsService;

    /**
     * 对某个动态的评论列表
     * 先让单条动态能正常展示
     * @return
     */
    @GetMapping
    public ResponseEntity commentList(Long page, Long pagesize, String movementId){
        PageResult pageResult = commentsService.commentList(page,pagesize,movementId);
        return ResponseEntity.ok(pageResult);
    }

    /**
     * 发表评论
     * @param paramMap
     * @return
     */
    @PostMapping
    public ResponseEntity addComment(@RequestBody Map<String,String> paramMap){
        commentsService.add(paramMap);
        return ResponseEntity.ok(null);
    }
}
